package com.xcl.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class Result<T> {

    private Integer code;    //状态码,1: 成功   0：表示失败
    private String message;
    private T data;


    //成功的操作   有数据
    public static <T> Result<T> success(T data) {
        return new Result<>(1,"操作成功",data);
    }

    //成功的操作   没有数据
    public static <T> Result<T> success() {
        return new Result<>(1,"操作成功",null);
    }

    //失败的操作
    public static <T> Result<T> error(String message) {
        return new Result<>(0,message,null);
    }

}
